import Vue from 'vue';
import router from '@/pages/console/router/index';
import permission from '@/pages/console/store/permission';
import plugins from '../plugins/index';
import '@/utils/initAxiosConfig';
import '@/utils/checkTenantType';
import { accountingNumFormat, caching } from 'hussar-base';
import numeral from 'numeral';
import moment from 'moment';
import dayjs from 'dayjs';

import message from '@/utils/message';
import echarts from 'echarts';

Vue.prototype.$Crouter = router;
Vue.prototype.$myMessage = message;
Vue.prototype.$jump2Login = (tcode) => {
  let path = '/login';
  if (tcode) {
    path = path + '?tcode=' + tcode;
  }
  router.push(path);
};
Vue.prototype.$permission = permission;
Vue.prototype.$jumpToForbidden = () => {
  router.push('/Forbidden');
};
Vue.prototype.$jumpToEmpower = () => {
  router.push('/empower');
};
Vue.prototype.$jumpToLicense = () => {
  router.push('/license');
};

Vue.prototype.$accountingNumFormat = accountingNumFormat;
Vue.prototype.$numeral = numeral;
Vue.prototype.$moment = moment;
Vue.prototype.$dayjs = dayjs;

Vue.prototype.$echarts = echarts;

Vue.use(plugins);

// 缓存
if (window.cachingNamespace) {
  caching.local.init(window.cachingNamespace);
  caching.session.init(window.cachingNamespace);
}
